capture log close
log using "isq_results.log", replace text


//  program:    isq_results.do
//  task:      	main results
//  project:    poladopt



//  #0

version 14
set linesize 80
clear all
macro drop _all
set more off
set matsize 11000 



//  #1
//  load data

use "isq_poladopt.dta", clear



//  #2
//  table 1
local base ln_rgdpch_pwt71 grgdpchtl_pwt71 crisis_lv_B totfinasset_gfddV6 ///
	L_dpi12 OC imf_prgf5 imf_eff5 imf_sba5 

* Mod 1
eststo : logit defacto3N `base' c.polity2_polV2##c.society i.year i.cid
	testparm c.polity2_polV2##c.society
	estadd scalar jtsig =`r(p)'

* Mod 2
eststo : xtlogit defacto3N `base' c.polity2_polV2##c.society i.year , re
	testparm c.polity2_polV2##c.society
	estadd scalar jtsig =`r(p)'

* Mod 3
eststo : logit defacto3N `base' c.libdem_vdem71##c.society i.year i.cid
	testparm c.libdem_vdem71##c.society
	estadd scalar jtsig =`r(p)'

* Mod 4
eststo : xtlogit defacto3N `base' c.libdem_vdem71##c.society i.year , re
	testparm c.libdem_vdem71##c.society
	estadd scalar jtsig =`r(p)'
	
	
esttab using isq_tbl1.csv , replace nobase /// 
	b(3) se(3) drop(*cid* *year*) ///
	scalars("N N" "ll LogLikelihood" "chi2_c C2" "jtsig JointSig") ///
	sfmt(%12.0f %12.3f) obslast  ///
	star(* .1 ** .05 *** .01)
est clear




//  #3
//  table 2
local base ln_rgdpch_pwt71 grgdpchtl_pwt71 crisis_lv_B totfinasset_gfddV6 ///
	L_dpi12 OC imf_prgf5 imf_eff5 imf_sba5
	
foreach i in xconst2 v2xlg_legcon v2lgoppart v2psoppaut {
	eststo : logit defacto3N `base' c.`i'##c.society i.year i.cid
		testparm c.`i'##c.society
		estadd scalar jtsig =`r(p)'
		
	eststo : xtlogit defacto3N `base' c.`i'##c.society i.year , re
		testparm c.`i'##c.society
		estadd scalar jtsig =`r(p)'
	}
	
esttab using isq_tbl2.csv , replace nobase /// 
	b(3) se(3) drop(*cid* *year*) ///
	scalars("N N" "ll LogLikelihood" "chi2_c C2" "jtsig JointSig") ///
	sfmt(%12.0f %12.3f) obslast  ///
	star(* .1 ** .05 *** .01)
est clear	




//  #4
//  fig 2

local base ln_rgdpch_pwt71 grgdpchtl_pwt71 crisis_lv_B totfinasset_gfddV6 ///
	L_dpi12 OC imf_prgf5 imf_eff5 imf_sba5 

logit defacto3N `base' c.polity2_polV2##c.society i.year i.cid
	cap gen sample = e(sample)
	tab society if sample == 1
	
margins ///
	, dydx(polity2_polV2) at(society=(8.25(0.25)14.25)) vsquish level(90)  
	* Goldstein 11.25 and 11.5 separates sig and nonsig.

marginsplot /*
	*/ , /*noci*/ recast(line) recastci(rline) ciopts(lcolor(gs6) lpattern(dash) lwidth(vthin)) /*
	*/ graphregion(color(white)) legend(col(2) size(small)) /*
	*/ title("") /*
	*/ xtitle("Society" , size(vsmall)) xlabel(, labsize(vsmall)) /*
	*/ ytitle("Effect on the Probability of de facto Reform" , size(vsmall)) ylabel(, labsize(vsmall)) /*
	*/ addplot(hist society if sample == 1 & inrange(society , 8 , 15) /*
	*/ 	, yaxis(2) /*
	*/ 	ytitle("Density (Society)" , size(vsmall) axis(2)) /*
	*/ 	ylabel(, labsize(vsmall) axis(2)) /*
	*/ 	ytick(, axis(2)) /*
	*/ 	yscale(alt axis(2))  /*
	*/ 	color(gs10%50)) /*
	*/ 	legend(off)
		
graph save "isq_fig2.gph" , replace




//  #5
//  fig 1
use isq_poladopt_fig1.dta , clear

egen treftl = total(tref_B) , by(year)
egen finNrtl = total(finNrshift) , by(year)
collapse (max) treftl finNrtl , by(year)
line treftl finNrtl year if inrange(year , 1980 , 2005) , /*
	*/ yscale(r(0)) /*
	*/ legend(label(1 "De jure") label(2 "De facto")) /*
	*/ graphregion(color(white)) scheme(s2manual) 

	
graph save "isq_fig1.gph" , replace
		

log close
clear
exit
		
